package org.assistant.csp.dao;

import org.assistant.common.exception.GetFromDBException;
import org.assistant.common.exception.SaveIntoDBException;
import org.assistant.csp.data.Home;
import org.assistant.csp.data.UserSession;

public interface UserDao {
	/**
	 * 判断登录账号是否在系统中已经存在
	 * 
	 * @param loginAccount
	 * @return
	 * @throws GetFromDBException
	 */
	public boolean isLoginAccountExist(String loginAccount)
			throws GetFromDBException;

	/**
	 * 判断email在系统中是否已经存在
	 * 
	 * @param email
	 * @return
	 * @throws GetFromDBException
	 */
	public boolean isEmailExist(String email) throws GetFromDBException;

	/**
	 * 根据用户账号获取用户信息
	 * 
	 * @param loginAccount
	 * @return
	 * @throws GetFromDBException
	 */
	public UserSession getUserByLoginAccount(String loginAccount)
			throws GetFromDBException;

	/**
	 * 根据用户ID(系统内码)获取用户信息
	 * 
	 * @param userId
	 * @return
	 * @throws GetFromDBException
	 */
	public UserSession getUserByUserId(String userId) throws GetFromDBException;

	/**
	 * 判断密码是否正确
	 * 
	 * @param loginZh
	 * @param password
	 * @return
	 * @throws GetFromDBException
	 */
	public boolean isPasswordCorrect(String loginZh, String password)
			throws GetFromDBException;

	/**
	 * 保存用户(注册)信息
	 * 
	 * @param userSession
	 *            -用户Session信息
	 * @param password
	 *            -密码
	 * @param home
	 *            -家庭信息
	 * @return UserSession
	 * @throws SaveIntoDBException
	 * @throws GetFromDBException
	 */
	public UserSession insertUser(UserSession userSession, String password,
			Home home) throws SaveIntoDBException, GetFromDBException;
}
